# 支持的最低版本
cmake_minimum_required(VERSION 3.0)

# 项目名称
project(project_name)

# 可执行文件名称
set(OUT_EXEC "main")

# 源文件目录
aux_source_directory(./ SRC_LIST)

# 头文件路径
include_directories(./)

# 添加编译参数
add_compile_options(-Os -g -std=gnu99)

# 设置可执行文件输出路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})

# 设置库文件输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/out/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/out/lib)

# 链接库的路径
link_directories(./)

# 生成可执行文件
add_executable(${OUT_EXEC} ${SRC_LIST})

# 添加链接库
target_link_libraries(${OUT_EXEC} )

# # 添加子目录
# add_subdirectory(utils)

# # 生成程序后执行命令
# add_custom_command(TARGET ${OUT_EXEC}
#                     POST_BUILD 
#                     COMMAND echo "generate test"
#                     COMMAND cp ${EXECUTABLE_OUTPUT_PATH}/${OUT_EXEC} ${EXECUTABLE_OUTPUT_PATH}/test
#                     VERBATIM 
# )

# # 生成程序前执行命令
# exec_program(rm ./ 
#             ARGS -f ${EXECUTABLE_OUTPUT_PATH}/test)
